package org.example.seckill.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author woopsion
 * @date 2025-06-28
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RespBean {
    private long code;
    private String message;
    private Object data;
    
    public static RespBean success(Object data){
        return 
                new RespBean(RespBeanEnum.SUCCESS.getCode()
                        ,RespBeanEnum.SUCCESS.getMessage()
                        ,data);
    }

    /**
     * 成功之后不携带任何数据
     * @return
     */
    public static RespBean success(){
        return 
                new RespBean(RespBeanEnum.SUCCESS.getCode()
                        ,RespBeanEnum.SUCCESS.getMessage(),null);
    }
    
    public static RespBean error(RespBeanEnum respBeanEnum){
        return new RespBean(respBeanEnum.getCode(),
                respBeanEnum.getMessage(),null);
    }
    public static RespBean error(Object data){
        return new RespBean(RespBeanEnum.Error.getCode(), 
                RespBeanEnum.Error.getMessage(), data);
    }
    public static RespBean error(RespBeanEnum respBeanEnum,Object data){
        return new RespBean(respBeanEnum.getCode(),
                respBeanEnum.getMessage(),data);
    }
    
    
}
